package app.server.project.main.service.controller;

import app.server.project.core.constants.Def;
import app.server.project.core.http.CMSLstResp;
import app.server.project.core.http.RespModel;
import app.server.project.main.service.dto.BalanceDto;
import app.server.project.main.service.dto.CommonLuckOrderDto;
import app.server.project.main.service.dto.LuckSumDto;
import app.server.project.main.service.dto.MyLuckOrderDto;
import app.server.project.main.service.dto.withdraw.WithDrawReq;
import app.server.project.main.service.service.luck.BTCLuckService;
import app.server.project.main.service.service.luck.SOLLuckService;
import app.server.project.main.service.service.luck.SOLRateService;
import app.server.project.main.service.service.withdraw.WithDrawService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 抽奖
 */
@AllArgsConstructor
@RestController
@RequestMapping("/luck")
public class LuckController {

    private final BTCLuckService btcLuckService;
    private final WithDrawService withdrawService;
    private final SOLLuckService solLuckService;
    private final SOLRateService solRateService;

    /**
     * 获取用户所有BTC抽奖订单
     *
     * @param userId
     * @return
     */
    @RequestMapping("/getMyAllBtc")
    public RespModel<List<MyLuckOrderDto>> getMyAllBtc(@RequestHeader(Def.UserId) long userId) {
        return RespModel.success(btcLuckService.getMyAllBtc(userId));
    }

    /**
     * 获取所有公共BTC抽奖订单
     *
     * @return
     */
    @RequestMapping("/getAllBtcCommon")
    public RespModel<List<CommonLuckOrderDto>> getAllBtcCommon() {
        return RespModel.success(btcLuckService.getAllBtcCommon());
    }

    /**
     * 获取用户所有SOL抽奖订单
     *
     * @param userId
     * @return
     */
    @RequestMapping("/getMyAllSOL")
    public RespModel<List<MyLuckOrderDto>> getMyAllSOL(@RequestHeader(Def.UserId) long userId) {
        return RespModel.success(solLuckService.getMyAllSOL(userId));
    }

    /**
     * 获取所有公共SOL中奖订单
     *
     * @return
     */
    @RequestMapping("/getAllSOLCommon")
    public RespModel<List<CommonLuckOrderDto>> getAllSOLCommon() {
        return RespModel.success(solLuckService.getAllSOLCommon());
    }

    /**
     * 提现ton币
     *
     * @param req
     * @return
     */
    @PostMapping("/doWithDraw")
    public RespModel<Boolean> doTonWithDraw(@RequestBody WithDrawReq req, @RequestHeader(Def.UserId) long userId) {
        return RespModel.success(withdrawService.doTonWithDraw(req, userId));
    }

    /**
     * 获取用户ton余额
     *
     * @param userId
     * @return
     */
    @PostMapping("/getBalance")
    public RespModel<BalanceDto> getBalance(@RequestHeader(Def.UserId) long userId) {
        return RespModel.success(btcLuckService.getBalance(userId));
    }

    /**
     * 获取抽奖数据
     *
     * @return
     */
    @RequestMapping("/getLuckData")
    public CMSLstResp<LuckSumDto> getLuckData() {
        return solLuckService.getLuckData();
    }

    /**
     * 获取所有公共SOL倍率中奖订单
     *
     * @return
     */
    @RequestMapping("/getAllSOLRateCommon")
    public RespModel<List<CommonLuckOrderDto>> getAllSOLRateCommon() {
        return RespModel.success(solRateService.getAllSOLRateCommon());
    }

    /**
     * 获取用户所有SOL倍率中奖订单
     *
     * @param userId
     * @return
     */
    @RequestMapping("/getMyAllSOLRate")
    public RespModel<List<MyLuckOrderDto>> getMyAllSOLRate(@RequestHeader(Def.UserId) long userId) {
        return RespModel.success(solRateService.getMyAllRateSOL(userId));
    }
}
